package com.elot.dto;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.springframework.stereotype.Component;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@Component
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ReferenceDto {

	private Key id;
	
	private String name;
	private String url;
	private Integer note;
	
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	public Key getId() {
		return id;
	}
	public void setId(Key id) {
		this.id = id;
	}
	
	public ReferenceDto() {
	}
	
	public ReferenceDto(Long id, String name, String url, Integer note) {
		if (id!=null)
			this.id = new KeyFactory.Builder(this.getClass().getSimpleName(), id).getKey();
		this.name = name;
		this.url = url;
		this.note = note;
	}
	
	@Persistent
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Persistent
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	
	@Persistent
	public Integer getNote() {
		return note;
	}
	public void setNote(Integer note) {
		this.note = note;
	}

}
